package ferp.android.views.table.element.tutorial;

import android.content.Context;
import android.graphics.Color;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.Gravity;
import android.widget.ScrollView;
import ferp.android.GUI;
import ferp.android.R;
import ferp.android.views.EnhancedTextView;

/**
 * User: olegs
 * Date: 22/04/2015 2:21 PM
 */
public class ScrollableTextView extends ScrollView
{
  public ScrollableTextView(Context context)
  {
    this(context, null, android.R.attr.scrollViewStyle);
  }

  public ScrollableTextView(Context context, AttributeSet attrs)
  {
    this(context, attrs, android.R.attr.scrollViewStyle);
  }

  public ScrollableTextView(Context context, AttributeSet attrs, int defStyle)
  {
    super(context, attrs, defStyle);

    int padding = GUI.dp2px(context.getResources(), 4);

    tv = new EnhancedTextView(context);

    tv.setTextColor(Color.WHITE);
    tv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 14);
    tv.setGravity(Gravity.LEFT);
    tv.setPadding(padding, padding, padding, padding);

    //setBackgroundResource(R.drawable.bg_tutorial_note);
    setBackgroundResource(R.drawable.dlg_background);
    setFillViewport(true);
    setSmoothScrollingEnabled(true);
    // always show vertical scrollbar
    setScrollbarFadingEnabled(false);
    setVerticalScrollBarEnabled(true);

    addView(tv);
  }

  @Override
  public void setOnClickListener(OnClickListener ocl) {tv.setOnClickListener(ocl);}

  public void setText(String text) {tv.setText(text);}
  public void setTextColor(int color) {tv.setTextColor(color);}

  private final EnhancedTextView tv;
}
